package cn.itcast.dmp.tags
import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.Row
//对关键词进行封装，因为关键词有多个，所以要进行分割
object Tags4KeyWordsMaker extends TagsMaker {
  override def make(row: Row, dic: Map[String, String]): Map[String, Double] = {
    val keyWords = row.getAs[String]("keywords")
    // b. 判断并行分割
    if (StringUtils.isNotBlank(keyWords)){
      keyWords.trim.split(",")
        .filter(kw => StringUtils.isNotBlank(kw))
        .map(kw => s"KW@@$kw" ->1.0).toMap
    }else{
      Map[String,Double]()
    }



  }
}
